package com.library.web.controller.library;


import com.library.common.annotation.Log;
import com.library.common.core.controller.BaseController;
import com.library.common.core.domain.AjaxResult;
import com.library.common.core.page.TableDataInfo;
import com.library.common.enums.BusinessType;
import com.library.common.utils.poi.ExcelUtil;
import com.library.domain.MbSignRecord;
import com.library.service.IMbSignRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List;


/**
 * 公众号签到 信息操作处理
 *
 * @author null
 * @date 2020-04-23
 * @blame Android Team
 */
@RestController
@RequestMapping("/library/mbSignRecord")
public class MbSignRecordController extends BaseController {
    private String prefix = "business/mobile/mbSignRecord";

    @Autowired
    private IMbSignRecordService mbSignRecordService;

    /**
     * 查询公众号签到列表
     */
    @PreAuthorize("@ss.hasPermi('library:mbSignRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(MbSignRecord mbSignRecord) {
        startPage();
        List<MbSignRecord> list = mbSignRecordService.selectMbSignRecordList(mbSignRecord);
        return getDataTable(list);
    }

    /**
     * 导出公众号签到列表
     */
    @PreAuthorize("@ss.hasPermi('library:mbSignRecord:export')")
    @Log(title = "公众号签到", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MbSignRecord mbSignRecord) {
        List<MbSignRecord> list = mbSignRecordService.selectMbSignRecordList(mbSignRecord);
        ExcelUtil<MbSignRecord> util = new ExcelUtil<MbSignRecord>(MbSignRecord.class);
        util.exportExcel(response, list, "公众号签到数据");
    }

    /**
     * 获取公众号签到详细信息
     */
    @PreAuthorize("@ss.hasPermi('library:mbSignRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(mbSignRecordService.selectMbSignRecordById(id));
    }

    /**
     * 新增公众号签到
     */
    @PreAuthorize("@ss.hasPermi('library:mbSignRecord:add')")
    @Log(title = "公众号签到", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MbSignRecord mbSignRecord) throws ParseException {
        return toAjax(mbSignRecordService.insertMbSignRecord(mbSignRecord));
    }

    /**
     * 修改公众号签到
     */
    @PreAuthorize("@ss.hasPermi('library:mbSignRecord:edit')")
    @Log(title = "公众号签到", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MbSignRecord mbSignRecord) {
        return toAjax(mbSignRecordService.updateMbSignRecord(mbSignRecord));
    }

    /**
     * 删除公众号签到
     */
    @PreAuthorize("@ss.hasPermi('library:mbSignRecord:remove')")
    @Log(title = "公众号签到", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mbSignRecordService.deleteMbSignRecordByIds(ids));
    }
}
